package com.wl.shop.entity;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import com.wl.shop.utils.UserUtils;

public class LongIdDataEntity extends Model<BaseEntity> implements Serializable{
	private static final long serialVersionUID = 1L;
	/**
	 * 实体编号（唯一标识）
	 */
	@TableId(type=IdType.AUTO)
	protected Long id;
	
	protected String remarks;	// 备注
	@TableField("create_by")
	protected String createBy;	// 创建者
	@TableField("create_date")
	protected Date createDate;	// 创建日期
	@TableField("update_by")
	protected String updateBy;	// 更新者
	@TableField("update_date")
	protected Date updateDate;	// 更新日期
	@TableField("is_del")
	protected Boolean isDel; 	// 是否删除
	
	public LongIdDataEntity() {
		// TODO Auto-generated constructor stub
		this.isDel = false;
	}
	public LongIdDataEntity(Long id){
		this.id = id;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getRemarks() {
		return remarks;
	}
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	public String getCreateBy() {
		return createBy;
	}
	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public String getUpdateBy() {
		return updateBy;
	}
	public void setUpdateBy(String updateBy) {
		this.updateBy = updateBy;
	}
	public Date getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	public Boolean getIsDel() {
		return isDel;
	}
	public void setIsDel(Boolean isDel) {
		this.isDel = isDel;
	}

	public void preInsert() {
		// TODO Auto-generated method stub
		User user = UserUtils.getUser();
		if (StringUtils.isNotBlank(user.getId())){
			this.createBy = user.getId();
		}
		this.createDate = new Date();
	}

	public void preUpdate() {
		// TODO Auto-generated method stub
		User user = UserUtils.getUser();
		if (StringUtils.isNotBlank(user.getId())){
			this.updateBy = user.getId();
		}
		this.updateDate = new Date();
	}
	
	/** 指定主键 */
	  @Override
	  protected Serializable pkVal() {
	      return this.id;
	  }
}
